package com.aizuda.boot.modules.business.contract.mapper;

import com.aizuda.boot.modules.business.contract.entity.ContractWorkflowTypeEntity;
import com.aizuda.boot.modules.business.contract.entity.dto.ProcessKeyTypeCache;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ContractWorkflowTypeMapper extends BaseMapper<ContractWorkflowTypeEntity> {


    @Select("""
            SELECT
            	process_key, priority
            FROM
            	contract_workflow cw
            	INNER JOIN contract_workflow_type cwt ON cw.id = cwt.workflow_id
            WHERE contract_type_id = #{typeId}
            ORDER BY cw.priority DESC
            LIMIT 1
            """)
    ProcessKeyTypeCache getMaxProcessKeyByType(@Param("typeId") Integer typeId);
}